package com.fulu.game.bi.entity;

import cn.hutool.core.date.DateUtil;
import com.fulu.game.bi.entity.enums.QueryTypeStatusEnum;
import lombok.Data;

import java.io.Serializable;

@Data
public class BaseVO implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * 开始时间
     */
    private String startDate;
    /**
     * 结束时间
     */
    private String endDate;

    /**
     * 日期
     */
    private String statDate;

    /**
     * 查询类型 1日 2周 3月
     */
    private Integer queryType;


    public String getEndDate() {
        QueryTypeStatusEnum anEnum = QueryTypeStatusEnum.getEnum(getQueryType());
        String endDate = null;
        switch (anEnum) {
            case DAY:
                endDate = getStatDate();
                break;
            case WEEK:
                endDate = DateUtil.formatDate(DateUtil.offsetDay(DateUtil.parse(getStatDate()), 6));
                break;
            case MONTH:
                endDate = DateUtil.formatDate(DateUtil.offsetDay(DateUtil.offsetMonth(DateUtil.parse(getStatDate() + "-01"), 1), -1));
                break;
            default:
                break;
        }
        return endDate;
    }

    public String getStartDate() {
        QueryTypeStatusEnum anEnum = QueryTypeStatusEnum.getEnum(getQueryType());
        String startDate = null;
        switch (anEnum) {
            case DAY:
            case WEEK:
                startDate = getStatDate();
                break;
            case MONTH:
                startDate = getStatDate() + "-01";
                break;
            default:
                break;
        }
        return startDate;
    }

}
